package com.biz.primus.model.sso.auth.vo;

import org.apache.commons.lang3.builder.ToStringBuilder;

import java.io.Serializable;

/**
 * Created by younger on 17/11/3.
 * 统一权限，具体的值和该服务上报的数据相关，参看:{@linkplain GrantedAuthority#authority}
 */
public class GrantedAuthority implements Serializable {
    private static final long serialVersionUID = -5872586775423152828L;

    /**
     * 理论上Spring Security中的值类似于: ROLE_USER;OPT_USER_EDIT
     */
    private String authority;

    public GrantedAuthority(){

    }

    public GrantedAuthority(String authority){
        this.authority = authority;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        GrantedAuthority that = (GrantedAuthority) o;

        return authority != null ? authority.equals(that.authority) : that.authority == null;
    }

    @Override
    public int hashCode() {
        return authority != null ? authority.hashCode() : 0;
    }

    @Override
    public String toString() {
        return ToStringBuilder.reflectionToString(this);
    }

    /**
     * {@linkplain GrantedAuthority#authority}
     */
    public String getAuthority() {
        return authority;
    }

    /**
     * {@linkplain GrantedAuthority#authority}
     */
    public void setAuthority(String authority) {
        this.authority = authority;
    }

}
